<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/html5.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/respond.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/admin/lib/PIE_IE678.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/lib/icheck/icheck.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/static/h-ui.admin/css/style.css" />
    <!--[if IE 6]>
    <script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>角色管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray"> <span class="l">
		<a class="btn btn-primary radius" href="javascript:;" onclick="admin_add('添加管理员','<?php echo Url('Admin/adminAdd')?>','800')"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a> </span> <span class="r">共有数据：<strong><?php echo $result['count']?></strong> 条</span> </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="6">添加管理员</th>
            </tr>
            <tr class="text-c">
                <th width="25"><input type="checkbox" value="" name=""></th>
                <th width="40">ID</th>
                <th width="100">登陆名</th>
                <th>所属角色</th>
                <th width="40">状态</th>
                <th width="70">操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach($result['list'] as $v){?>
            <tr class="text-c" <!--<?php if($v['id'] == 1) echo 'style="display:none;"'?>-->
            <td><input type="checkbox" value="" name=""></td>
            <td><?php echo $v['id']?></td>
            <td><?php echo $v['username']?></td>
            <td><?php echo $v['title']?></td>
            <td class="td-status"><span class="label <?php echo $v['status'] == 1 ? 'label-success' : 'label-defaunt';?> radius"><?php echo $v['status'] == 0 ? '已启用' : '已禁用';?></span></td>

            <td class="td-manage" >
                <?php if($v['status'] == 1){?>
                <a href="javascript:;" title="禁用" onclick="stop(this,'<?php echo $v['id']?>','<?php echo $v['status']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>
                <?php } else if($v['status'] == 2) {?>
                <a href="javascript:;" title="启用" onclick="start(this,'<?php echo $v['id']?>','<?php echo $v['status']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e1;</i></a>
                <?php }?>
                <a style="text-decoration:none" class="ml-5" onClick="change_password('修改密码','<?php echo Url('admin/adminChangePassword',array('id'=>$v['id']))?>')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
                <a title="编辑" href="javascript:;" onclick="admin_edit('管理员编辑','<?php echo Url('admin/adminSave',array('id'=>$v['id']))?>',<?php echo $v['id']?>)" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
            </td>
            </tr>
            <?php } ?>
            </tbody>
        </table>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/lib/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
    /*密码-修改*/
    function change_password(title,url,id,w,h){
        layer_show(title,url,w,h);

    }
    /*管理员-添加*/
    function admin_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-编辑*/
    function admin_edit(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-删除*/
    function admin_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type:'get',
                url:"<?php echo Url('Admin/adminDelete')?>",
                data:{"id":id},
                success:function(data){
                    if(data.code == 0){
                        layer.msg(data.errormsg,{icon:1,time:1000});
                    }else{
                        layer.msg(data.errormsg,{icon:5,time:1000});
                    }

                }
            });
            //此处请求后台程序，下方是成功后的前台处理……
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }
    /*停用*/
    function stop(obj,id,status){
        layer.confirm('确认要停用吗？',function(index){
            $.ajax({
                type:'post',
                url:"<?php echo url('Admin/adminStatusChange')?>",
                data:{"id":id,"status":status},
                success:function(data){
                    if(data.code == 0){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="start(this,'+id+','+data.data.status+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已禁用</span>');
                        $(obj).remove();
                        layer.msg('已禁用！',{icon: 7,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }

    /*启用*/
    function start(obj,id,status){
        layer.confirm('确认要启用吗？',function(index){
            $.ajax({
                type:'post',
                url:"<?php echo url('Admin/adminStatusChange')?>",
                data:{"id":id,"status":status},
                success:function(data){
                    if(data.code == 0){
                        $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="stop(this,'+id+','+data.data.status+')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe631;</i></a>');
                        $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                        $(obj).remove();
                        layer.msg('已启用！',{icon: 1,time:1000});
                    }else{
                        layer.msg(data.msg,{icon:5,time:1000});
                    }
                }
            });
        });
    }
</script>
</body>
</html>